home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 735 / 735.xpi / chrome / answers.jar / content / options.js < prev    next >
Text File  |  2009-12-13  |  3KB  |  98 lines

  1. // create the base ANSW object if it does not exist.
  2.  if (typeof ANSW=="undefined") {
  3.      ANSW = new Object();
  4.  }
  5. ANSW.optionsDataBoolean = new Array();
  6. // Initializes the options dialog
  7.  
  8. ANSW.Init = function(nafid,cobrand)
  9. {
  10.     ANSW.nafid = nafid;
  11.     ANSW.cobrand = cobrand;
  12. };
  13.  ANSW.initializeOptions = function()
  14. {
  15.     if (ANSW.modifierKey.get()=="ctrlKey")
  16.     {
  17.         document.getElementById("answers.action.altclick").label="The Ctrl key and the left or right mouse button";
  18.         document.getElementById("answers.action.default").label="The Ctrl key and the right mouse button";
  19.         document.getElementById("alt.caption").label="Ctrl-click";
  20.     }
  21.     const preferencesService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("answers.");
  22.     if(preferencesService.prefHasUserValue("action.altclick"))
  23.     {
  24.         var select = preferencesService.getBoolPref("action.altclick");
  25.         if (select==true)
  26.             document.getElementById("answers.radiogroup").selectedIndex = 0;
  27.         else
  28.             document.getElementById("answers.radiogroup").selectedIndex = 1;
  29.     }
  30.     else
  31.         document.getElementById("answers.radiogroup").selectedIndex = 0;
  32.     if(preferencesService.prefHasUserValue("view.answertip"))
  33.     {
  34.         var select = preferencesService.getBoolPref("view.answertip");
  35.         if (select==true)
  36.             document.getElementById("answertip.radiogroup").selectedIndex = 0;
  37.         else
  38.             document.getElementById("answertip.radiogroup").selectedIndex = 1;
  39.     }
  40.     else
  41.         document.getElementById("answertip.radiogroup").selectedIndex = 0;
  42.  
  43.     
  44. };
  45. // Saves the user's options
  46.  ANSW.saveOptions = function()
  47. {
  48.     
  49.     const preferencesService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
  50.     var option      = null;
  51.     ANSW.optionsDataBoolean["answers.action.altclick"]    = document.getElementById("answers.action.altclick").selected;
  52.     
  53.      ANSW.optionsDataBoolean["answers.view.answertip"]    = document.getElementById("answers.view.answertip").selected;
  54.  
  55.      
  56.     // Loop through the boolean options
  57.     for(option in ANSW.optionsDataBoolean)
  58.     {
  59.        preferencesService.setBoolPref(option,ANSW.optionsDataBoolean[option]);
  60.     }
  61. };
  62.  
  63. ANSW.modifierKey = {
  64.     get: function () {
  65.         return this.searchString(this.dataOS) || "an unknown modKey";
  66.     },
  67.     searchString: function (data) {
  68.         for (var i=0;i<data.length;i++)    {
  69.             var dataString = data[i].string;
  70.             if (dataString) {
  71.                 if (dataString.indexOf(data[i].subString) != -1)
  72.                     return data[i].modKey;
  73.             }
  74.         }
  75.     },
  76.     dataOS : [
  77.         {
  78.             string: navigator.platform,
  79.             subString: "Win",
  80.             identity: "Windows",
  81.             modKey: "altKey"
  82.         },
  83.         {
  84.             string: navigator.platform,
  85.             subString: "Mac",
  86.             identity: "Mac",
  87.             modKey: "altKey"
  88.         },
  89.         {
  90.             string: navigator.platform,
  91.             subString: "Linux",
  92.             identity: "Linux",
  93.             modKey: "ctrlKey"
  94.         }
  95.     ],
  96. };
  97.  
  98.